package com.masterclient.app.businessmodule.vipmodule.persenter;

import com.eoner.baselib.container.CommonBaseResponse;
import com.eoner.baselib.presenter.FCBaseCallBack;
import com.eoner.baselib.presenter.FCBasePresenter;
import com.masterclient.app.businessmodule.vipmodule.api.SaleOrderListService;
import com.masterclient.app.businessmodule.vipmodule.bean.SellerOrderDetail;

import java.util.HashMap;
import java.util.Map;

public class SellerDetailPresenter extends SellerDetailContract.Presenter {

    @Override
    public void sellerOrderDetail(String orderNo, int scene) {
        mView.baseShowPageLoading(false);
        mRxManager.add(toNewSubscribe(SaleOrderListService.getInstance().sellerOrderDetail(orderNo, scene),
                new FCBaseCallBack<CommonBaseResponse<SellerOrderDetail>>() {
                    @Override
                    public void onSuccess(CommonBaseResponse<SellerOrderDetail> bean) {
                        mView.succ(bean.getData());
                    }

                    @Override
                    public void onNetWorkError(String errorMsg) {
                        super.onNetWorkError(errorMsg);
                        mView.error(FCBasePresenter.WEB_FAILED_STR);
                    }

                    @Override
                    public void onServiceError(CommonBaseResponse<SellerOrderDetail> obj) {
                        super.onServiceError(obj);
                        mView.error(FCBasePresenter.SERVER_FAILED_STR);
                    }
                }));
    }

    @Override
    public void sellerOrderPush(String orderId) {
        mView.baseShowCommitLoading("");
        Map<String,String> map = new HashMap<>();
        map.put("order_id",orderId);
        mRxManager.add(toNewSubscribe(SaleOrderListService.getInstance().sellerOrderPush(map),
                new FCBaseCallBack<CommonBaseResponse<Object>>() {
                    @Override
                    public void onSuccess(CommonBaseResponse bean) {
                        mView.orderPushsucc(bean.getMsg());
                    }

                    @Override
                    public void onNetWorkError(String errorMsg) {
                        super.onNetWorkError(errorMsg);
                        // mView.error(FCBasePresenter.WEB_FAILED_STR);
                    }

                    @Override
                    public void onServiceError(CommonBaseResponse obj) {
                        super.onServiceError(obj);
                        // mView.error(FCBasePresenter.SERVER_FAILED_STR);
                    }
                }));
    }

}
